{{ template "_internal/google_analytics.html" . }}
<script src="//code.jquery.com/jquery-3.1.1.min.js" integrity="sha256-hVVnYaiADRTO2PzUGmuLJr8BLUSjGIZsDYGmIJLv2b8="
    crossorigin="anonymous"></script>
<script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
    integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
    crossorigin="anonymous"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.4/jstree.min.js"></script>

<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-cookie/1.4.1/jquery.cookie.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/waypoints/4.0.1/jquery.waypoints.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/Counter-Up/1.0/jquery.counterup.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery-parallax/1.1.3/jquery-parallax.js"></script>
<script src="{{ .Site.BaseURL }}js/front.js"></script>

<!-- owl carousel -->
<script src="{{ .Site.BaseURL }}js/owl.carousel.min.js"></script>

<!-- used to for mobile -->
<script src="{{ .Site.BaseURL }}js/flexible.js"></script>
<script src="{{ .Site.BaseURL }}js/common.js"></script>

<script src="{{ .Site.BaseURL }}js/dist/jso.js"></script>
<script src="{{ .Site.BaseURL }}js/cla.js?t=20191230"></script>
<div id="mask" onclick="hideNav()"></div>

<script type="text/javascript">
    $(document).ready(function () {

        function getRelativePath() {
            var url = location.href;
            var arrURL = url.split("//");
            return arrURL[1].substring(arrURL[1].indexOf("/"));
        }

        function getCurrentID(wholeData, relativeURL) {
            for (var j in wholeData) {
                var href = wholeData[j].a_attr.href;
                var text = wholeData[j].text;
                //debugger;
                if ((href == relativeURL) || (text.indexOf(relativeURL) >= 0)) {
                    //console.log(wholeData[j].id);
                    return wholeData[j].id;
                } else {
                    if (wholeData[j].children.length > 0) {
                        var v = getCurrentID(wholeData[j].children, relativeURL);
                        if (v != "") {
                            return v;
                        }
                    }
                }
            }
            return "";
        }

        if ($('#docstreeview').length) {
            $('#docstreeview').jstree();
            $('#docstreeview').jstree().hide_dots();
            $('#docstreeview').jstree().hide_icons();
            $('#docstreeview').on("changed.jstree", function (e, data) {
                if (data.node) {
                    var link = data.node.a_attr.href;
                    if (link == "" || link == "#") {
                        var aElementID = "#" + data.node.id + "_anchor";
                        var aElement = $(aElementID).find("a");
                        if (aElement.length) {
                            link = aElement.attr("href");
                        }
                    }
                    console.log(link);
                    var relativeURL = getRelativePath();
                    console.log(relativeURL);
                    if (link != relativeURL) {
                        location.href = link;
                    }
                }
            });

            /* select the node by the relative url
            var currentAElement = $('#docstreeview').find("a[href='" + getRelativePath() + "']");
            if (currentAElement.length) {
                console.log("click");
                currentAElement.trigger("click");
            }*/

            $("#docstreeview").on("ready.jstree", function (e, data) {
                $("#docstreeview").fadeIn("slow")
                var relativeURL = getRelativePath();
                var wholeData = $("#docstreeview").jstree().get_json();
                var currentID = getCurrentID(wholeData, relativeURL);
                console.log(currentID);
                $("#docstreeview").jstree()._open_to(currentID);
                $('#docstreeview').jstree().select_node(currentID);
            });
        }
        function showNav() {
            $('#menu').css({
                "transform": "translateX(0)"
            }).attr("onoff", "on");
        }
        function hideNav() {
            $('#menu').css({
                "transform": "translateX(-100%)"
            }).attr("onoff", "off");
        }

        $("#slideNav").bind('click', function () {
            if ($('#menu').attr("onoff") == "on") {
                hideNav();
            } else {
                showNav();
            }
        })
    });
</script>
